<!-- 任务详情/列表 -->
<template>
	<view class="index">
		<!-- <view class="uni-card"> -->
			<view class="uni-list">
				<view class="uni-list-cell">
					{{data.title && data.title.title}}：{{data.title && data.title.value}}
				</view>
				<view class="uni-list-cell">
					{{data.code && data.code.title}}：{{data.code && data.code.value}}
				</view>
				<view class="uni-list-cell">
					{{data.statement_type && data.statement_type.title}}：{{data.statement_type && data.statement_type.value}}
				</view>
				
				<view class="uni-list-cell-divider" v-if="data.client_info">
					{{data.client_info.title}}：
					<text >{{data.client_info.value.company_name}}</text>
				</view>
				<view class="uni-list-cell con-list" v-if="data.client_info">
					<text >地址 : {{data.client_info.value.company_address}}</text>
					<text >姓名 : {{data.client_info.value.company_contacts}}</text>
					
					<text @click="phoneCall(data.client_info.value.company_tel)">电话 : {{data.client_info.value.company_tel}}</text>
				</view>
				
				<view class="uni-list-cell-divider" v-if="data.customer_info">
					{{data.customer_info.title}}：
					<text >{{data.customer_info.value.company_name}}</text>
				</view>
				<view class="uni-list-cell con-list" v-if="data.customer_info">
					<text >地址 : {{data.customer_info.value.company_address}}</text>
					<text >姓名 : {{data.customer_info.value.company_contacts}}</text>
					
					<text @click="phoneCall(data.customer_info.value.company_tel)">电话 : {{data.customer_info.value.company_tel}}</text>
				</view>
				
				<view class="uni-list-cell-divider" v-if="data.sample_user && data.sample_user.value">
					{{data.sample_user && data.sample_user.title}}：
					<text>{{data.sample_user && data.sample_user.value}}</text>
				</view>
				<view class="uni-list-cell-divider" v-else>
					采样人员 ：
					
				</view>
				
				
				
				<view class="uni-list-cell no-left">
					{{data.sampleend && data.sampleend.title}}：{{data.sampleend && data.sampleend.value ?data.sampleend && data.sampleend.value :''}}
				</view>
				
				<view class="uni-list-cell no-left">
					{{data.samplestart && data.samplestart.title}}：{{data.samplestart && data.samplestart.value ? data.samplestart && data.samplestart.value : ''}}
				</view>
				
				<view class="uni-list-cell no-left">
					{{data.remark && data.remark.title}}：{{data.remark && data.remark.value ? data.remark && data.remark.value : ''}}
				</view>
				
				<view class="uni-list-cell-divider" v-if="listData && listData.length != 0">
					采样计划：
				</view>
				<view class="uni-list-cell sample-list" v-if="listData && listData.length != 0">
					<view v-for="(item, index) in listData" :key="index">
						<view class="uni-list no-before" v-if="item">
							<view class="uni-list-cell">采样地点：{{item.location_id || '未填写'}}</view>
							<view class="uni-list-cell">检测类型(数量)：{{item.item_type_id && item.item_type_id.name}} ({{ ((item.item_id && item.item_id.length) || 0) }}个检测项目)</view>
							<view class="uni-list-cell">
								<text class="width-auto">检测项目：</text>
								<view class="width-a100">
									<!--  #ifdef MP-WEIXIN -->
									<text clsss="mar_right" v-for="(vItem, vIndex) in item.item_id" :key="vIndex">{{vItem.name || ''}}</text>
									<!--  #endif -->
									<!--  #ifdef APP-PLUS -->
									<text clsss="mar_right" v-for="(vItem, vIndex) in item.item_id" :key="vIndex" v-html="vItem.name || ''"></text>
									<!--  #endif -->
								</view>
							</view>
						</view>
					</view>
				</view>

			</view>
		<!-- </view> -->
		<view class="btn-row uni-flex win-fixed">
			<button type="primary" class="primary uni-flex-item" style="margin-right: 10upx;" @tap="goSampleList">样品列表</button>
			<button type="primary" class="primary uni-flex-item" @tap="goSamplingList"> 
				{{data.isLoadData == '已上传' ? '查看' : '填写'}}采样记录
			</button>
		</view>
		
		<view class="user-fixed user-tips"  v-if="isTips"></view>
		<view class="user-fixed user-tips-container" v-if="isTips">
			<view class="fixed-relative">
				<view class="tips-content">点击可修改或添加现场采样点；可查看采样标准及采样注意事项。</view>
				<view class="tips-btns">
					<text @click="clickTips">我知道了</text>
				</view>
				<view class="relation">
					<!-- <text class="arrowthinup"></text>
					<view class="hei"></view> -->
					<view class="tip-bg"></view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	
	import net from '../../net.js';
	import service from '../../service.js';
	import utils from '../../common/utils.js';
	
	export default {
		data() {
			return {
				data: {},
				listData: [],
				isTips: true,
				tipsCount: null,
				codeId: '',
				isLogo:'',
			}
		},
		onLoad(res) {
			console.log(res)
			this.isLogo = res.isLogo;
			this.data = {}; 
			this.isTips = true;
			let data = JSON.parse(res.data);
			this.codeId = data && data.code && data.code.value;
			Object.assign(this.data, data);//将源对象合拼到目标对象上(第一个是目标对象,第一个以后都是源对象)
			this.tipsCount = service.getTips();
			if(this.tipsCount != null && this.tipsCount >= 3) this.isTips = false;
			this.getData();
		},
		methods: {
			getData() {
				net.netGet('/module/api/main/statementsampleList/'+encodeURIComponent(this.codeId), {}, (res)=>{
					this.listData = res;
					console.log(JSON.stringify(res),"getdata");
				}, ()=>{
					
				}, (res)=> {
					
				});	
			},
			goSamplingList() {
				let param = utils.toParam({data: this.data,isLogo :this.isLogo,codeId:this.codeId});
				uni.navigateTo({
					url: "./sampling_list"+param
				});
			},
			goSampleList() {
				// console.log('this.data----',this.data)
				let param = utils.toParam({data: this.data});
				uni.navigateTo({
					url: "./sample_list"+param
				});
			},
			phoneCall(num) {
				uni.makePhoneCall({ phoneNumber: num });
			},
			clickTips() {
				if(isNaN(Number(this.tipsCount))) this.tipsCount = 0;
				this.tipsCount++;
				this.isTips = false;
				service.setTips(this.tipsCount);
			}
		},
	}
</script>

<style scoped lang="scss">
	.index{
		width: 100%;
	}
	.sample-list{
		view{
			width: 100%;
		}
	}
	
	.uni-card {
		margin: 50upx 0 165upx 0;
	}
	
	.btn-row {
		margin-top: 0;
	}
	
	.uni-list-cell:after {
		left: 0;
		height: 0;
	}
	
	.uni-list-cell {
		padding: 0 20upx;
		min-height: 90upx;
		color: #666;
	}
	
	.uni-list-cell.con-list {
		flex-wrap: wrap;
	}
	
	.uni-list-cell.con-list text {
		flex: 0 0 100%;
		font-size: 32upx;
	}
	
	.uni-list-cell-divider ~ .uni-list-cell {
		padding-left: 50upx;
		min-height: 70upx;
	}
	
	.uni-list-cell.no-left {
		padding-left: 20upx;
	}
	
	.win-fixed {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		background-color: #fff;
		z-index: 5;
	}
	
	.fixed {
		position: relative;
	}
	
	.user-fixed {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 6;
	}
	
	.user-tips {
		background-color: #000;
		opacity: 0.5;
	}
	
	.user-tips-container {
		z-index: 10;
	}
	
	.tips-content {
		position: absolute;
		left: 0;
		right: 0;
		color: #fff;
		bottom: 500upx;
		padding: 10upx 15upx;
		font-size: 44upx;
	}
	
	.tips-btns {
		text-align: center;
		position: absolute;
		left: 0;
		right: 0;
		bottom: 200upx;
		z-index: 12;
	}
	
	.relation {
		position:absolute;
		left:50rpx;
		bottom:140upx;
	}
	
	.hei {
		height:330rpx;
		background-color:#fff;
		width:24rpx;
		margin-left: 17rpx;
		margin-top:-15rpx;
	}
	
	.arrowthinup {
		height: 0;
		width: 0;
		border-width: 30rpx;
		border-style: dashed dashed solid dashed;
		border-color: transparent transparent #fff transparent;
		display: inline-block;
	}
	
	.tips-btns text {
		color:#fff;
		border:1px solid #fff;
		padding: 10upx;
		border-radius: 40px;
		font-size: 48upx;
	}
	
	.sample-list {
		flex-direction: column;
	}
	
	.sample-list .uni-list-cell {
		padding: 0;
		min-height: 60upx;
		font-size: 30upx;
	}
	
	.sample-list .width-auto {
		margin: 0;
	}
	
	.tip-bg {
		background: url('../../static/img/tip.png') no-repeat;
		height: 350upx;
		width: 270upx;
	}
	.uni-list:after {
              z-index: 0; 
	}
	.mar_right{
		margin-right: 10upx;
	}
</style>
